//简历模块
import router from '../../router'
import axios from 'axios'

const $host = 'http://132.232.110.185/personnelManagement'

export default {
    namespaced: true,
    actions: {
        //修改请求
        async updateRequestInfo(ctx, obj) {
            await axios({
                method: 'POST',
                url: `${$host}/talents/addUpdateTalents`,
                headers: {
                    'Content-Type': 'application/json'
                },
                data:
                    {
                        "qq": obj.qq || null,
                        "tCity": obj.tCity || null,
                        "tAge": obj.tAge || null,
                        "tDesIimg": obj.tDesIimg || null,
                        "tEducation": obj.tEducation || null,
                        "tEmail": obj.tEmail || null,
                        "tFirstDate": obj.tFirstDate || null,
                        "tHeight": obj.tHeight || null,
                        "tHoue": obj.tHoue || null,
                        "tId": obj.tId || null,
                        "tIdCard": obj.tIdCard || null,
                        "tIfTime": obj.tIfTime || null,
                        "tImg": obj.tImg || null,
                        "tImgCard": obj.tImgCard || null,
                        "tJob": obj.tJob || null,
                        "tNP": obj.tNP || null,
                        "tName": obj.tName || null,
                        "tNation": obj.tNation || null,
                        "tPStatus": obj.tPStatus || null,
                        "tPasswrod": obj.tPasswrod || null,
                        "tPhone": obj.tPhone || null,
                        "tRemark": obj.tRemark || null,
                        "tSalary": obj.tSalary || null,
                        "tSex": obj.tSex || null,
                        "tSkill": obj.tSkill || null,
                        "tStatus": obj.tStatus || null,
                        "tStudy": obj.tStudy || null,
                        "tWeight": obj.tWeight || null,
                        "tWork": obj.tWork || null,
                        "tBloom": obj.tBloom || null
                    }
            }).then(res => {
                let n = 1
                if (res.data.msg === "修改成功" && obj.tBloom === "" || null || undefined) ctx.commit('saveBasicInfo', n)
                if (obj.tBloom !== "" || null || undefined) ctx.commit('saveBasicInfo')
            }).catch(err => {
                console.log(err);
            })
        },
    },
    mutations: {
        // 回到上一个路由
        preBack(state) {
            router.back()
        },
        //跳下一个路由
        next(state, name) {
            router.push({name})
        },
        //保存基本资料
        saveBasicInfo(state, n) {
            if (n === 1) router.push({name: 'detail'})
            else router.push({name: 'attachment'})
        },
    },
    state: {
        educations: [{
            value: '初中以下',
            label: '初中以下'
        }, {
            value: '初中',
            label: '初中'
        }, {
            value: '高中/中专',
            label: '高中/中专'
        }, {
            value: '大专',
            label: '大专'
        }, {
            value: '本科',
            label: '本科'
        }, {
            value: '硕士',
            label: '硕士'
        }, {
            value: '博士',
            label: '博士'
        }],
        dateType: [{
            value: '公历',
            label: '公历'
        }, {
            value: '农历',
            label: '农历'
        }],
        jobs: [{
            value: '销售',
            label: '销售'
        }, {
            value: '财务',
            label: '财务'
        }, {
            value: '策划',
            label: '策划'
        }, {
            value: '人事',
            label: '人事'
        }]
    },
    getters: {}
}